package com.union.controller.app;

import com.union.base.api.R;
import com.union.biz.service.message.TextStrategySelector;
import com.union.controller.app.vo.TextProcessReqVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "返利联盟 - 文本处理")
@RestController
@Slf4j
@RequestMapping("/union/text")
@Validated
public class AppTextProcessController {

    @Resource
    private TextStrategySelector textStrategySelector;

    @PostMapping("/process")
    @Operation(summary = "处理文本消息")
    public R<Object> processText(@Valid @RequestBody TextProcessReqVO reqVO) {
        Object result = textStrategySelector.process(
                reqVO.getRequest(),
                reqVO.getOpenId(),
                reqVO.getUserType()
        );
        return R.ok(result);
    }
}
